package day19;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * a b 字符串的最长公共子串
 *
 * @author wileda
 * @date 2023/03/26  19:23
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String str1 = scanner.nextLine();
            String str2 = scanner.nextLine();
            String str = commonStr(str1,str2);
            System.out.println(str);
        }
    }

    private static String commonStr(String str1, String str2) {
        String str = "";
        String max = str1.length() >= str2.length()?str1:str2;
        String min = str1.length() >= str2.length()?str2:str1;
        int left = 0;
        int right = left + 1;
        while(right <= min.length()){
            String temp = min.substring(left,right);
            if(max.contains(temp)) {
                if (str.length() < temp.length()) {
                    str = temp;
                }
                right++;
            }else {
                    left++;
                    right = left + 1;
                }
            }
        return str;
        }
    }


